﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Brouteforce.Animation {
    public class LinearMovementTransition : Transition {
        public Vector2 StartPosition;
        public Vector2 EndPosition;
        private Vector2 _nsteps;

        public LinearMovementTransition(double duration, Vector2 startPosition, Vector2 endPosition)
            : base(duration) {
            StartPosition = startPosition;
            EndPosition = endPosition;
        }

        public override void startTransition() {
            _nsteps = new Vector2(EndPosition.X - StartPosition.X, EndPosition.Y - StartPosition.Y);
            base.startTransition();
        }

        public override void interpolate(GameTime time) {
            var t = Time / Duration;
            Value = t;
        }

        public Vector2 CurrentPosition {
            get {
                return new Vector2((float)(StartPosition.X + _nsteps.X * Value), (float)(StartPosition.Y + _nsteps.Y * Value));
            }
        }
    }
}
